<template>
  <div>
    <el-menu :default-active="this.$router.path" class="el-menu-vertical-demo" unique-opened router @open="handleOpen"
      @close="handleClose" :collapse="isCollapse" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b"
      style="height:calc(100%);">
      <el-menu-item index="/home">
        <i class="el-icon-menu"></i>
        <span slot="title">首页</span>
      </el-menu-item>

      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-house"></i>
          <span>仓库管理</span>
        </template>
        <el-submenu index="1-1">
          <template slot="title">
            <span>入库管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/addin" style="color: cornflowerblue;">新增入库单</el-menu-item>
            <el-menu-item index="/detailin" style="color: cornflowerblue;">入库单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="1-2">
          <template slot="title">
            <span>出库管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/addout" style="color: cornflowerblue;">新增出库单</el-menu-item>
            <el-menu-item index="/detailout" style="color: cornflowerblue;">出库单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="1-3">
          <template slot="title">
            <span>库存管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="detaildepot" style="color: cornflowerblue;">库存详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-submenu>


      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-shopping-cart-full"></i>
          <span>采购管理</span>
        </template>
        <el-submenu index="1-1">
          <template slot="title">
            <span>需求单</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/addneed" style="color: cornflowerblue;" 
            v-if="(role.endsWith('m') || role.endsWith('manager') || role.endsWith('x')) && userAll.sid == 6"
            >新增需求单</el-menu-item>
            <el-menu-item index="/detailneed" style="color: cornflowerblue;">需求单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>

        <el-submenu index="1-3">
          <template slot="title">
            <span>采购单</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="detailbuy" style="color: cornflowerblue;">采购单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title">
          <i class="el-icon-s-data"></i>
          <span>销售管理</span>
        </template>
        <el-submenu index="1-1">
          <template slot="title">
            <span>选货单管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/addchoose" style="color: cornflowerblue;">新增选货单</el-menu-item>
            <el-menu-item index="/detailchoose" style="color: cornflowerblue;">选货单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="1-2">
          <template slot="title">
            <span>打包单管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/addpack" style="color: cornflowerblue;">新增打包单</el-menu-item>
            <el-menu-item index="/detailpack" style="color: cornflowerblue;">打包单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="1-3">
          <template slot="title">
            <span>结算单管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="/adddeposit" style="color: cornflowerblue;">新增结算单</el-menu-item>
            <el-menu-item index="/detaildeposit" style="color: cornflowerblue;">结算单详情</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
      </el-submenu>


      <el-submenu index="4"
      v-if="userAll.sid == 3 || role == 'manager'">
        <template slot="title">
          <i class="el-icon-s-finance"></i>
          <span>财务管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/addmoney" style="color: cornflowerblue;">客户充值管理</el-menu-item>
          <el-menu-item index="/account" style="color: cornflowerblue;">交易管理</el-menu-item>
          <el-menu-item index="/item" style="color: cornflowerblue;">客户账单管理</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="5">
        <template slot="title">
          <i class="el-icon-s-goods"></i>
          <span>商品管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/managergoods" style="color: cornflowerblue;">产品管理</el-menu-item>
          <el-menu-item index="/concergoods" style="color: cornflowerblue;">产品关注</el-menu-item>
          <el-menu-item index="/saleprice" style="color: cornflowerblue;">销售定价</el-menu-item>
        </el-menu-item-group>
      </el-submenu>


      <el-submenu index="6">
        <template slot="title">
          <i class="el-icon-s-cooperation"></i>
          <span>合作管理</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/client" style="color: cornflowerblue;">客户管理</el-menu-item>
          <el-menu-item index="/vendor" style="color: cornflowerblue;">供应商管理</el-menu-item>
          <el-menu-item index="/concerclient" style="color: cornflowerblue;">关注客户</el-menu-item>
        </el-menu-item-group>
      </el-submenu>



      <el-submenu index="7">
        <template slot="title">
          <i class="el-icon-box"></i>
          <span>基础物料</span>
        </template>
        <el-menu-item-group>
          <el-menu-item index="/area" style="color: cornflowerblue;">区域管理</el-menu-item>
          <el-menu-item index="/meter" style="color: cornflowerblue;">物料分类</el-menu-item>
          <el-menu-item index="/category" style="color: cornflowerblue;">品类管理</el-menu-item>
          <el-menu-item index="/producter" style="color: cornflowerblue;">产品线管理</el-menu-item>
          <el-menu-item index="/purity" style="color: cornflowerblue;">产品成色</el-menu-item>
        </el-menu-item-group>
      </el-submenu>





      <el-submenu index="8">
        <template slot="title">
          <i class="el-icon-setting"></i>
          <span>系统设置</span>
        </template>
        <el-menu-item-group>
          
          
          <el-menu-item index="/systemuser" style="color: cornflowerblue;">用户管理</el-menu-item>
          <!-- <el-menu-item index="addbuy" style="color: cornflowerblue;">修改密码</el-menu-item> -->
          <el-menu-item index="/systemrole" style="color: cornflowerblue;"
            v-if="role.endsWith('m') || role.endsWith('manager') || role.endsWith('x')">角色管理</el-menu-item>
          <el-menu-item index="/warehouse" style="color: cornflowerblue;"
            >仓库管理</el-menu-item>
          <el-menu-item index="/exporting" style="color: cornflowerblue;"  v-if=" role.endsWith('manager')" >导出任务</el-menu-item>
        </el-menu-item-group>
      </el-submenu>

      <el-menu-item index="/managermember">
        <i class="el-icon-s-custom"></i>
        <span slot="title">会员管理</span>
      </el-menu-item>
      <el-menu-item index="/addbuy">
        <i class="el-icon-edit-outline"></i>
        <span slot="title">修改密码</span>
      </el-menu-item>



    </el-menu>
  </div>
</template>
<script>
export default {
  name: "mainLeft",

  data() {
    return {
      isCollapse: false,
      role: '',
      //保存该账号的信息
      userAll: null,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  },
  mounted: function () {
    this.$axios
      .get("/user/findUserByAccount/" + window.localStorage.getItem("account"))
      .then(res => {
        console.log(res.data.data);
        this.userAll = res.data.data;
        this.role = res.data.data.roleList[0].name;
        console.log(this.role);
      });
  }
};
</script>
<style  scoped></style>
